﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Cms.BLL
{
    public class PageLog:BaseDao<Model.PageLog,int>
    {
        private static List<Model.PageLog> CacheLog = new List<Cms.Model.PageLog>();

        private static object lockobj = new object();
        public void AddLog(Model.PageLog model) {
            lock (lockobj)
            {
                CacheLog.Add(model);
            }
            CommitLog(50);
        }
        //提交日志
        public void CommitLog(int count) {
            if (CacheLog.Count >= count)
            {
                //this.CurrentSession.BeginTransaction();
                for (int i = 0; i < CacheLog.Count;i++ )
                {
                    Model.PageLog m = CacheLog[i];
                    this.Save(m);
                    CacheLog.Remove(m);
                }
                this.CommitChanges();
            }
        }
        //提交所有的日志
        public void CommitAll() {
            CommitLog(CacheLog.Count);
        }
    }
}
